package com.scs.application.modules.finance.controller;

import com.scs.application.core.mvc.controller.FlowController;
import com.scs.application.modules.finance.entity.Settlement;
import com.scs.application.modules.finance.service.SettlementService;
import com.scs.application.modules.sys.model.RestResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/finance/settlement")
public class SettlementController extends FlowController<SettlementService, Settlement> {

    /**
     * 同步帐单至供应商平台
     * @param settlement
     * @return
     */
    @PostMapping("/syncMSCM")
    public RestResult syncToMSCM(@RequestBody Settlement settlement) {
        service.syncToMSCM(settlement);
        return RestResult.ok();
    }


    /**
     * 导出帐单 供应商平台导入使用
     * @param settlement
     * @return
     */
    @PostMapping("/getDataForMSCM")
    public RestResult getDataForMSCM(@RequestBody Settlement settlement) throws IOException {
        return RestResult.ok("操作成功", service.getDataForMSCM(settlement));
    }
}
